home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
RESOURCE.DOC
< prev
next >
Wrap
Text File
|
1986-01-28
|
26KB
|
772 lines
RESOURCE
A disassembler for 8080 programs
by Ward Christensen
CP/M U.G. 1/80
Suggestions? Call me eve's at (312) 849-6279
----------------
RESOURCE commands are inconsistent at best. - RESOURCE is a
kludge based on years of disassembler experience and hacking,
and was never "planned" - just coded sitting at a tube, and
modified over 2 years before being contributed to the CP/M UG.
For example, to kill a symbol: k.label but to kill a
control value: caddr,k and to kill a comment: ;addr,
but RESOURCE does the job like no other I have seen.
----------------
N-O-T-E: Pardon the editorial, but I feel hardware without
good software is useless to 99% of us. Most good software
has to be paid for. I strongly support the legitimate purchase
of licensed software. I do not regularly use any programs
which I have not purchased. (Yes, I do occasionally "try"
one, but then buy it if I plan on using it). I have been
asked by software businesses to NOT distribute RESOURCE -
because of it's ability to produce good .asm source quickly.
But, there are so many disassemblers out, why not a good,
conversational one? Please use it in the spirit in which it
was contributed: to enlarge your understanding of the micro-
computer world around you, and to allow you to customize
programs which you legitimately own, for your own use.
"Semper non rippus offus"
----
NOTE: any command taking a hex address (Dnnnn, etc)
may take a value in the form .label but arithmetic
may not be performed. (i.e. d.start is ok, but d.start+8 not)
----------------
Overall structure of RESOURCE: It is a .COM file,
which runs at 100H. It goes thru 1700 or so, then the stack.
At 1800 is a 512 entry table for control commands. Each is
3 bytes long, and controls the format of the re-sourced list,
i.e. is it DB, DS, DW, instructions, etc.
At 1E00 is the start of the symbol table. It has no
defined length as such. If it is not used, it occupies only
2 bytes.
If you want to re-source something which is in memory,
such as a PROM, a program previously loaded in high memory,
"CP/M itself", or whatever, you can just do so.
However, typically you want to disassemble a program
which runs at 100H, which is were RESOURCE runs. Bob
Van Valzah would have solved that by making resource
relocatable and moving itself up under BDOS. I wasn't that
industrious.
Instead, RESOURCE uses the concept of an "invisible"
OFFSET. After all, what do you care where it is as long
as it LOOKS like it's at 100h?
So, you set an offset. O2F00 sets it to 2F00 Hex.
Reading a .COM file (RFOO.COM) causes it to come into 3000 on.
If you say D100 or L100 it dumps or lists what LOOKS like your
program. Internally, RESOURCE is adding the offset to the
D and L addresses.
What should you set the offset to? Well, that depends
upon how many symbols you will use. O1F00 will load the
program at 2000, thus allowing only 1E00-1FFF for symbols,
i.e. 512 bytes or about 50-60 labels. If you didn't leave
enough space, then used B to build a default symbol table,
the table could run into and clobber your .com file! (easy
recovery, however: just change the offset to being higher,
and read in the .COM file again) Each entry takes 3 bytes
+ the symbol length, and if you like 7 byte labels like I
do, that means 10 bytes/label. An offset of 2F00 should
be adequate.
If you want to put comments into the disassembled
program, you will have to designate an area to Use for the
comments. The U command (e.g. U4000) specifies what area
is to be used.
Before issuing the O (offset) command, do:
L5 7
which will show the JMP to BDOS, which is the highest memory
you may use. (Note if you have, for example, an empty 4K
memory board in high memory, you can Use THAT for comments).
Let's take an example: You have an 8K file, FOO.COM
which you want to disassemble. It will have about 300 labels.
300 x 10 is 3000, or call it 4K (what's a K unless your
tight). The symbol table starts at 1E00. 4K more is 2E00.
Let's load the .COM at 2E00, so since it normally starts
at 100H, the offset is 2D00. O2D00 is the command.
We then RFOO.COM to read it in. It says 4E00 2100 which
means it came into actual memory to 4E00, but 2100 if we
are talking with respect to loading at 100.
Thus, we could set our comments table up after
the .COM program - say at 5000: U5000
The ? command shows the memory utilization for
control, symbol, and comments entries. (no, I never put
in anything to keep track of the .COM - you'll just have
to do that yourself).
If you ever want to dump real memory, you'll have
to reset the offset to 0: O0 but then set it back.
If you are not sure what it is, typing O will tell the
current offset.
Hoo, boy! Hope this kludge of documentation
is enough to get you going - hmmm, better give you
some of the gotcha's I've discovered...
---- WATCH FOR ----
* Symbols overflowing into the .COM.
(Use ? command to see how full symbol table is)
* Control entries overflowing into .SYM (altho I
can't believe anyone will have a program with
more than 512 control entries!!!)
* Comments overflowing into BDOS (ug!!)
* Using an offset which is not in free memory
and overlaying BDOS or whatever.
* The B(uild) command gobbling up too much when building
a DB: "B" will take a DB 'GOBBELDY GOOK' followed
by LXI H,FOO and take the LXI as a '!' (21H) so
you'll have to manually stick a new "I" control
entry in at the address of the LXI. You might
also delete the incorrect "I" entry which RESOURCE
stuck in (typically at the second byte of the LXI)
* Trying to dump real memory without setting the
offset back to 0. (then forgetting to set it back
to its proper value)
* Forgetting how big the .COM file you are disassembling
was.
* Using RESOURCE to rip off software (yes, I know, you
heard that before, but only 3 in 100 needed to be
told, and 2 in 100 needs to be told again, and 1 in
100 doesn't give a rat's fuzzy behind anyway!!)
* Forgetting to take checkpoints when disassembling
large files. You may even want to rotate the names
under which things are saved:
STEMP1.SYM
STEMP1.CTL
STEMP1.DOC
* Missing a label: Suppose you have a control entry
for a DW, resulting in:
DFLT: ;172C
DW 100H
but somewhere in the program, the following exists:
LDA 172DH
Even if you did a B and have a label L172D, it won't
show up since it's in the middle of a DW. Instead,
do this:
K.l172d kill the old label
e172d,.dflt+1 put in the new label as a displacement
off the beginning.
* improperly disassembling DW's (see previous item).
You might be tempted to make DFLT a DB so that
DFLT: ;172C
DB 0
L172D: ;172D
DB 1
Note that while this disassembles and reassembles
properly, it is not "as correct" as the technique
used in the previous item.
* Having the "B" command overlay your "E" control entry.
What? Well, "B"uild is pretty dumb. If he finds 8
DB type characters in a row, he fires off a DB from
then on until he runs out of those characters. Suppose
your program was 200 long (ended at 3FF), and you
had zeroed (aha! Nice DB candidates) memory there
(there meaning at your offset address + whatever).
Then you QB100,400 and viola!! RESOURCE overlaid
your "E" control with a "B".
----------------
RESOURCE is relatively complete. (well, actually,
the phrase "rampant featureitis" has been "mentioned").
...But there's always another day, and another K...
SO... Here's my "wish list"
..it might save you telling me YOU think such-and-such
would be nice...
* Targets of LHLD, SHLD should automatically be flagged
as type DW in the control table. Ditto LDA and STA
as DB or as second half of DW. Ditto targets of LXI
as DB (?).
* E5C,.FCB
followed by
E6C,.FCB+
should automatically calculate the appropriate
displacement, and put it in the symbol table.
* The comments facility should be enhanced to allow
total SUBSTITUTION of entire line(s) of